package net.ojbk.sso.center.web.handlers;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import javax.xml.crypto.Data;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: twobox
 * Date: 2019/3/28
 * Time: 17:06
 * Description: No Description
 */
@Controller
@RequestMapping(value = "/")
public class TestController {
    @RequestMapping("test")
    public ResponseEntity<Object> test(HttpSession session) {
        String s = "This website is good.";
        System.out.println("session.getCreationTime()：" + new Date(session.getCreationTime()));
        System.out.println("session.getLastAccessedTime()：" + new Date(session.getLastAccessedTime()));
        System.out.println("session.getId()：" + session.getId());
        System.out.println("session.getMaxInactiveInterval()：" + session.getMaxInactiveInterval());
        System.out.println("剩余过期时间（s）：" + (session.getMaxInactiveInterval() - (int) (new Date().getTime() - session.getLastAccessedTime()) / 1000) + 1);
        return new ResponseEntity<>("剩余过期时间（s）：" + (session.getMaxInactiveInterval() - (int) (new Date().getTime() - session.getLastAccessedTime()) / 1000), HttpStatus.OK);
    }

}
